<?php


/******************************************************************************/
if (!defined('PLUGINS')) define('PLUGINS', APP . 'plugins' . DS);
if (!defined('ADMIN')) define('ADMIN', PLUGINS . 'admin' . DS);
if (!defined('ADMIN_MODELS')) define('ADMIN_MODELS', ADMIN . 'models' . DS);
if (!defined('ADMIN_BEHAVIORS')) define('ADMIN_BEHAVIORS', ADMIN_MODELS . 'behaviors' . DS);
if (!defined('ADMIN_CONTROLLERS')) define('ADMIN_CONTROLLERS', ADMIN . 'controllers' . DS);
if (!defined('ADMIN_COMPONENTS')) define('ADMIN_COMPONENTS', ADMIN_CONTROLLERS . 'components' . DS);
if (!defined('ADMIN_VIEWS')) define('ADMIN_VIEWS', ADMIN . 'views' . DS);
if (!defined('ADMIN_HELPERS')) define('ADMIN_HELPERS', ADMIN_VIEWS . 'helpers' . DS);
if (!defined('ADMIN_LAYOUTS')) define('ADMIN_LAYOUTS', ADMIN_VIEWS . 'layouts' . DS);
if (!defined('ADMIN_ELEMENTS')) define('ADMIN_ELEMENTS', ADMIN_VIEWS . 'elements' . DS);
/******************************************************************************/
//if (!defined('JS_DIR')) define('JS_DIR', 'js' . DS);
//if (!defined('CSS_DIR')) define('CSS_DIR', 'css' . DS);
//if (!defined('XML_DIR')) define('XML_DIR', 'xml' . DS);
//if (!defined('SWF_DIR')) define('SWF_DIR', 'swf' . DS);
//if (!defined('IMAGES_DIR')) define('IMAGES_DIR', 'img' . DS);
//if (!defined('FILES_DIR')) define('FILES_DIR', 'files' . DS);
//if (!defined('AUDIO_DIR')) define('AUDIO_DIR', 'audio' . DS);
//if (!defined('VIDEO_DIR')) define('VIDEO_DIR', 'video' . DS);
/******************************************************************************/
//if (!defined('HTDOCS_DIR')) define('HTDOCS_DIR', WWW_ROOT);

//if (!defined('HTDOCS_JS_DIR')) define('HTDOCS_JS_DIR', HTDOCS_DIR . JS_DIR);
//if (!defined('HTDOCS_CSS_DIR')) define('HTDOCS_CSS_DIR', HTDOCS_DIR . CSS_DIR);
//if (!defined('HTDOCS_XML_DIR')) define('HTDOCS_XML_DIR', HTDOCS_DIR . XML_DIR);
//if (!defined('HTDOCS_SWF_DIR')) define('HTDOCS_SWF_DIR', HTDOCS_DIR . SWF_DIR);
//if (!defined('HTDOCS_IMAGES_DIR')) define('HTDOCS_IMAGES_DIR', HTDOCS_DIR . IMAGES_DIR);
//if (!defined('HTDOCS_FILES_DIR')) define('HTDOCS_FILES_DIR', HTDOCS_DIR . FILES_DIR);
//if (!defined('HTDOCS_AUDIO_DIR')) define('HTDOCS_AUDIO_DIR', HTDOCS_DIR . AUDIO_DIR);
//if (!defined('HTDOCS_VIDEO_DIR')) define('HTDOCS_VIDEO_DIR', HTDOCS_DIR . VIDEO_DIR);
/******************************************************************************/
//if (!defined('JS_URL')) define('JS_URL', 'js/');
//if (!defined('CSS_URL')) define('CSS_URL', 'css/');
//if (!defined('XML_URL')) define('XML_URL', 'xml/');
//if (!defined('SWF_URL')) define('SWF_URL', 'swf/');
//if (!defined('IMAGES_URL')) define('IMAGES_URL', 'img/');
//if (!defined('FILES_URL')) define('FILES_URL', 'files/');
//if (!defined('AUDIO_URL')) define('AUDIO_URL', 'audio/');
//if (!defined('VIDEO_URL')) define('VIDEO_URL', 'video/');

if (!defined('LIBS_URL')) define('LIBS_URL', 'libs/');
/******************************************************************************/
if (!defined('WEBROOT_URL')) define('WEBROOT_URL', FULL_BASE_URL . rtrim(dirname(env('SCRIPT_NAME')), '/') . '/');
//
//if (!defined('WEBROOT_JS_URL')) define('WEBROOT_JS_URL', WEBROOT_URL . JS_URL);
//if (!defined('WEBROOT_CSS_URL')) define('WEBROOT_CSS_URL', WEBROOT_URL . CSS_URL);
//if (!defined('WEBROOT_XML_URL')) define('WEBROOT_XML_URL', WEBROOT_URL . XML_URL);
//if (!defined('WEBROOT_SWF_URL')) define('WEBROOT_SWF_URL', WEBROOT_URL . SWF_URL);
//if (!defined('WEBROOT_IMAGES_URL')) define('WEBROOT_IMAGES_URL', WEBROOT_URL . IMAGES_URL);
//if (!defined('WEBROOT_FILES_URL')) define('WEBROOT_FILES_URL', WEBROOT_URL . FILES_URL);
//if (!defined('WEBROOT_AUDIO_URL')) define('WEBROOT_AUDIO_URL', WEBROOT_URL . AUDIO_URL);
//if (!defined('WEBROOT_VIDEO_URL')) define('WEBROOT_VIDEO_URL', WEBROOT_URL . VIDEO_URL);

if (!defined('WEBROOT_LIBS_URL')) define('WEBROOT_LIBS_URL', WEBROOT_URL . LIBS_URL);
/******************************************************************************/
if (!defined('DATE_FORMAT')) define('DATE_FORMAT', 'H:i:s');
if (!defined('TIME_FORMAT')) define('TIME_FORMAT', 'Y-m-d');
if (!defined('DATETIME_FORMAT')) define('DATETIME_FORMAT', DATE_FORMAT . ' ' . TIME_FORMAT);
/******************************************************************************/
setlocale(LC_ALL, 'ru_RU.UTF-8');
/******************************************************************************/


Configure::write('Engine.name', 'Siluet2010 CMS');
Configure::write('Engine.version', '1.0.0');

// Firebug (FirePHP / FireCake)
Configure::write('fb', TRUE);

if (!function_exists('fb')) {
	function fb() {
		if ((bool)Configure::read('debug') && Configure::read('fb')) {
			if (!class_exists('FirePHP') && !class_exists('FireCake')) {
				App::import('Vendor', 'FirePHP', array('file' => 'FirePHP' . DS . 'FirePHP.class.php')) or App::import('Vendor', 'DebugKit.FireCake');
			}
			if (func_num_args() == 0) {
				$args = array('Test', 'FirePHP', 'info');
			} else {
				$args = func_get_args();
			}
			if (class_exists('FirePHP')) {
				$instance = FirePHP::getInstance(TRUE);
				return call_user_func_array(array($instance, 'fb'), $args);
			} elseif (class_exists('FireCake')) {
				return call_user_func_array(array('FireCake', 'fb'), $args);
			} elseif (func_num_args() > 0) {
				trigger_error(__('FirePHP could not be loaded', TRUE), E_USER_NOTICE);
			}
		}
		return FALSE;
	}
}

// gost 7.79 system b (russian)
Inflector::rules('transliteration', array(
	'/а/' => 'a', '/б/' => 'b', '/в/' => 'v', '/г/' => 'g', '/д/' => 'd', '/е/' => 'e', '/ё/' => 'yo', '/ж/' => 'zh', '/з/' => 'z', '/и/' => 'i', '/й/' => 'j',
	'/к/' => 'k', '/л/' => 'l', '/м/' => 'm', '/н/' => 'n', '/о/' => 'о', '/п/' => 'p', '/р/' => 'r', '/с/' => 's', '/т/' => 't', '/у/' => 'u', '/ф/' => 'f',
	'/х/' => 'h', '/ц/' => 'cz', '/ч/' => 'ch', '/ш/' => 'sh', '/щ/' => 'shh', '/ъ/' => '``', '/ы/' => 'y`', '/ь/' => '`', '/э/' => 'e`', '/ю/' => 'yu', '/я/' => 'ya',
	'/А/' => 'A', '/Б/' => 'B', '/В/' => 'V', '/Г/' => 'G', '/Д/' => 'D', '/Е/' => 'E', '/Ё/' => 'Yo', '/Ж/' => 'Zh', '/З/' => 'Z', '/И/' => 'I', '/Й/' => 'J',
	'/К/' => 'K', '/Л/' => 'L', '/М/' => 'M', '/Н/' => 'N', '/О/' => 'О', '/П/' => 'P', '/Р/' => 'R', '/С/' => 'S', '/Т/' => 'T', '/У/' => 'U', '/Ф/' => 'F',
	'/Х/' => 'H', '/Ц/' => 'Cz', '/Ч/' => 'Ch', '/Ш/' => 'Sh', '/Щ/' => 'Shh', '/Ъ/' => '``', '/Ы/' => 'Y`', '/Ь/' => '`', '/Э/' => 'E`', '/Ю/' => 'Yu', '/Я/' => 'Ya',
	'/’/' => '\'', '/№/' => '#', '/(c)z(?=[ieyj])/i' => '\1', '/[“”«»]/' => '"'
));

// project config
Configure::load('project');

// language
if (!defined('DEFAULT_LANGUAGE')) {
	define('DEFAULT_LANGUAGE', 'rus');
}
if (Configure::read('Config.language') === NULL) {
	Configure::write('Config.language', DEFAULT_LANGUAGE);
}


// for automating
Configure::write('Routing.autoLanguage', TRUE);
Configure::write('Routing.autoPage', FALSE);
Configure::write('Routing.autoPrefixes', array('admin'));
Configure::write('Routing.autoParams', array());
Configure::write('Routing.autoNamed', array('model', 'foreign_key'));
Configure::write('Routing.autoExtensions', array('frame'));


?>